#pragma once
#include "common.h"
#include "NesCPU.h"
#include "NesCPUBus.h"
#include "NesPPU.h"
#include "NesGamePad.h"
#include "NesCartridge.h"
#include <stdio.h>

#include "NesPAPU.h"

enum TiggleType {
    NMI_PENING = 0x1,
    IRQ_PENING = 0x2,
    IRQ_ONESHOT = 0x4,
    IRQ_DMC_INT = 0x2,
    IRQ_HSYNC_INT = 0x2,
    IRQ_FRAME_INT = 0x2,
};
void DebugPrintf(const char* strOutputString, ...);
class Famicom
{
private:
    bool mIsPalying = false;
    savebundle_t* savebundle_api = nullptr;
public:

    NesCPU* cpu = nullptr;
    NesCPUBus* cpubus = nullptr;
    NesPPU* ppu = nullptr;
    NesCartridge* cartridge = nullptr;
    NesGamePad* gamepad = nullptr;
    NesPAPU* apu = nullptr;
    SaveBundle* saveBundle = nullptr;
    Famicom();
    ~Famicom();
    void UserInput(uint8_t index, uint8_t state) const;
    uint8_t* GetCanvas() const;
    int16_t* GetSamples(uint32_t* size) const;
    int ReloadRom(char* rom, size_t size);
    void EmulationFrame() const;
    void RenderPattern(uint8_t* mem) const;
    void Save() const;
    void Restore() const;
    void Reset() const;
    void SetSavebundle(savebundle_t * save);
    void SetSavebundle(SaveBundle* isave);
    void Play();
    void Pause();
    

};

